<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ include file="/WEB-INF/jsp/common/taglib.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Index</title>
<link href="<s:url value="/css/standard.css" />" rel="stylesheet"
	type="text/css" />
<link href="<s:url value="/css/pop_up.css" />" rel="stylesheet"
	type="text/css" />
<link href="<s:url value="/css/maintenance.css" />" rel="stylesheet"
	type="text/css" />
<link href="<s:url value="/css/Simplemodal.css" />" rel="stylesheet"
	type="text/css" />

<script src='<c:url value="/js/common.js" />'></script>
<script src='<c:url value="/js/common_ui.js" />'></script>
<script src='<c:url value="/js/poplayer.js" />'></script>
<script src='<c:url value="/js/maint_ui.js" />'></script>

<script src='<c:url value="/js/jquery-1.7.2.js" />'></script>


</head>
<body>

	<div class="pageVar">
		<c:set var='pageIndex' value='${pageIndex}' />
		<c:set var='pageSize' value="${pageSize}" />
		<c:set var='totalPage' value="${totalPage}" />

		<c:set var='changePercent' value="0.7" />
		<c:set var='changeStepSize' value="1" />


		<c:set var='starPageIndex' value="0" />
		<c:set var='endPageIndex' value="${pageSize}" />
		<c:set var='changeStep' value="0" />

		<c:if test="${pageIndex >= pageSize * changePercent}">
			<c:set var='changeStep'
				value="${
					 ( 
			 			(pageIndex - endPageIndex * changePercent+1) 
							-
							(pageIndex - endPageIndex * changePercent+1) %1 ) * changeStepSize}" />
			<!-- 减去自身的余数*增加页数值 -->

		</c:if>

		<c:set var="starPageIndex" value="${starPageIndex+changeStep}"></c:set>

		<c:set var="endPageIndex" value="${endPageIndex+changeStep}"></c:set>

		<c:set var="needEndValue" value="true" />

		<c:if test="${endPageIndex >= totalPage}">
			<c:set var="endPageIndex" value="${totalPage}" />
			<c:set var="needEndValue" value="false" />
		</c:if>


		<c:set var="isShowOmitSign" value="false" />

		<c:if test="${needEndValue}">

			<c:set var="isShowOmitSign" value="${totalPage > (endPageIndex)}" />


		</c:if>

	</div>
	<form:form name="deleteForm" method="delete">
		<input type="hidden" name="id">
		<input type="hidden" id="deletIndex" name="pageIndex"
			value="${pageIndex} ">

	</form:form>

	<form:form name="toPage" method="get">
		<input type="hidden" id="pageIndex" name="pageIndex" value="">
	</form:form>

	<form:form name=" skip">
		<input type="hidden" id="skipPageIndex" name="skipPageIndex"
			value="${pageIndex} ">
		<input type="hidden" id="totalPage" name="totalPage"
			value="${totalPage} ">
	</form:form>

	<div class="Info">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="7" align="left" valign="top" height="7"><img
					src="<s:url value="/images/corner_left_top_m.gif"/>" width="7"
					height="7" /></td>
				<td class="topBorderMain"><img
					src="<s:url value="/images/spacer.gif" />" /></td>
				<td width="7" align="right" valign="top"><img
					src="<s:url value="/images/corner_right_top_m.gif" />" /></td>
			</tr>

			<tr>
				<th colspan="4" class="mainFormTitle">checkinfo</th>
			</tr>

			<tr>
				<td colspan="4" class="leftRightBorderMain">

					<table cellpadding="0" cellspacing="0" class="invoiceButton">
						<tr>
							<td><img src="<s:url value="/images/btn_add.gif"/>"
								name="btn_add.gif" align="absbottom" /> <a
								href="javascript:location.href='<c:url value='/checkinfo/add' />'">Add
									New </a></td>
						</tr>
					</table>
					<table id="radiotable" class="mainGrid" width="100%" border="0"
						cellpadding="0" cellspacing="0">
						<thead>
							<tr>
								<th width='20%'>id</th>
								<th width='10%'>chcekInTime</th>
								<th width='10%'>chcekOutTime</th>
								<th width='20%'>createdTime</th>
								<th width='20%'>employeeName</th>
								<th width='20%'>control</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${ list }" var="checkInfo" varStatus="status">
								<tr id="radiotable_tr_<c:out value="${status.index}"/>">
									<td align='center' width='20%'><a
										href="javascript:location.href='<c:url value='/employeeinfo/${ checkInfo.id }/view' />'">
											<c:out value="${ checkInfo.id }" />
									</a></td>

									<td align='center' style="word-break: break-all;"><fmt:formatDate
											value="${ checkInfo.chcekInTime }" pattern="MM/dd/yyyy HH:mm" /></td>
									<td align='center' width='10%' style="word-break: break-all;"><fmt:formatDate
											value="${ checkInfo.chcekOutTime }"
											pattern="MM/dd/yyyy HH:mm" /></td>
									<td align='center' width='20%' style="word-break: break-all;"><fmt:formatDate
											value="${ checkInfo.createdTime }" pattern="MM/dd/yyyy HH:mm" /></td>
									<td align='center' width='20%' style="word-break: break-all;">
										${ checkInfo.employeeName }</td>

									<td align='center' style="white-space: nowrap;" width='20%'>

										<a href="javascript:void(0);"
										onclick="deleteDemo('<c:out value='${ checkInfo.id }'/>')"><img
											src="<s:url value="/images/btn_remove.gif"/>"
											name="btn_remove.gif" alt="Remove" title="Remove" width="18"
											height="20" hspace="3" vspace="3" border="0"
											align="absmiddle" /></a>
									</td>
								</tr>
							</c:forEach>

							<c:if test="${ list == null || fn:length(list) == 0}">
								<tr id="radiotable_tr_<c:out value="${status.index}"/>">
									<td colspan='99' align='center'><font color='red'>no
											recored.</font></td>
								</tr>
							</c:if>
						</tbody>
					</table>
				</td>
			</tr>
			<tr>
				<th colspan="4" class="mainFormbtn">
					<table cellpadding="0" cellspacing="0" width="100%">
						<tr>
							<td align="center">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td align="center">

											<div class="pageColumn">
												<table width="100%">
													<td align="center"><form:form action="page"> 
																		页数：【    ${pageIndex+1} 】<a
																style="text-decoration: none;"
																<c:choose>
																
																 <c:when test="${pageIndex > 1}"> 
																href="javascript:goPage('${pageIndex-1}')"
																</c:when>
													
  					             					 			<c:otherwise>
  					             					 				 href="javascript:goPage('0')"
   															</c:otherwise>
   															
   																		</c:choose>>
																【上一页】</a>
															<a
																<c:choose>
																
																 <c:when test="${pageIndex+1 == totalPage}"> 
																href="javascript:goPage('${pageIndex}')"
																</c:when>
													
  					             					 			<c:otherwise>
  					             					 				 href="javascript:goPage('${pageIndex+1}')"
   															</c:otherwise>
   															
   																		</c:choose>
																style="text-decoration: none">【下一页】</a> 
														总页数：${totalPage}  &nbsp 跳转     <input
																style="text-align: center;" size="1" name="amount"
																value="" type="text" id="skip">
															<a
																style="text-decoration: none; font-size: 15px; cursor: pointer;"
																onclick="skip()">确定 </a>
														</form:form></td>

												</table>

											</div>

										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</th>

			</tr>
			<tr></tr>
			<tr>
				<td align="left" valign="bottom" height="7" width="7"><img
					src="<s:url value="/images/corner_left_bottom_m.gif"/>" /></td>
				<td class="bottomBorderMain"><img
					src="<s:url value="/images/spacer.gif"/>" /></td>
				<td align="right" valign="bottom" height="7" width="7"><img
					src="<s:url value="/images/corner_right_bottom_m.gif"/>" /></td>
			</tr>
		</table>

	</div>




	<br>

	<br>
	<br>
	<!-- 
 <div class="pageCodeShow" style="position: relative; bottom: 10px">
		<table id="radiotable" class="mainGrid" style="width: 100%;">

			<tr>
				<td class="pageTd" align="center" width="250px"><a name="home"
					onclick="goPage('0')" class="pageButton"
					style="cursor: pointer; font-size: large; text-decoration: none; color: #404040;">home</a>

					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <c:if
						test="${starPageIndex > 0}">
						<a name="previousPage" onclick="goPage('${pageIndex-1}')"
							class="pageButton"
							style="cursor: pointer; font-size: large; text-decoration: none; color: #404040;">上一页</a>

					</c:if></td>

				<c:forEach var="buttonCodeList" begin="${starPageIndex+1}"
					end="${endPageIndex}" step="1">

					<td class="pageTd" align="center" width="100px"><a
						name="buttonCode" onclick="goPage('${buttonCodeList-1}')"
						class="pageButton"
						style="cursor: pointer; text-decoration: none; color: #404040; font-size: 15px;">${buttonCodeList}</a>

					</td>
				</c:forEach>

				<td align="center" width="125px" class="pageTd"><c:if
						test="${needEndValue}">

						<c:if test="${isShowOmitSign}">
							<a name="totalPage" onclick="goPage('${totalPage}')"
								class="pageButton"
								style="cursor: pointer; text-decoration: none; color: #404040; font-size: 15px">...
								${totalPage}</a>
						</c:if>
						<c:if test="${!isShowOmitSign}">
							<a name="totalPage" onclick="goPage('${totalPage}')"
								class="pageButton"
								style="cursor: pointer; text-decoration: none; color: #404040;">${totalPage}</a>
						</c:if>
					</c:if></td>
				<td align="center" width="125px" class="pageTd"><c:if
						test="${endPageIndex < totalPage}">
						<a name="nextPage" onclick="goPage('${pageIndex+1}')"
							class="pageButton"
							style="cursor: pointer; font-size: large; text-decoration: none; color: #404040;">下一页</a>


					</c:if></td>
			</tr>

		</table>

	</div> -->
	<script type="text/javascript">
	
	function deleteDemo(id){
		if(confirm("Are you sure to delete this Record?")){
			
			
			deleteForm.action="<c:url value='/checkinfo/'/>" + id ;
			deleteForm.submit();
		}
	}
	
	function goPage(pageIndex){
		
		$('#pageIndex').val(pageIndex);
		
		toPage.action="<c:url value='/checkinfo/page'/>";
		
		toPage.submit();
	}
	
	function search() {
		searchForm.action="<c:url value='/checkinfo/page'/>";
		searchForm.submit();
	}
	
	function skip(){
		
		var skip =$("#skip").val();
		var skipPageIndex = $('#skipPageIndex').val();
		var totalPage = $('#totalPage').val();
		
		if(skip.split("").length<1){
			
			goPage(skipPageIndex);
		}
		else  if(skip>totalPage){
		
			totalPage = totalPage-1
			goPage(totalPage);
			
		}
			if(skip.split("").length>0&skip<totalPage)
			{
				skip = skip-1
				
			goPage(skip);}
	}
</script>

</body>

</html>